package com.fastloan.mgt.expert.controller;

import com.fastloan.mgt.expert.model.Expert;
import com.fastloan.mgt.expert.model.ExpertProduct;
import com.fastloan.mgt.expert.model.vo.ExpertVO;
import com.fastloan.mgt.expert.service.ExpertProductService;
import com.fastloan.mgt.expert.service.ExpertService;
import com.fastloan.safe.core.util.ManagerKit;
import com.kawins.base.baseabs.BaseController;
import com.kawins.result.ResultTo;
import com.kawins.supers.table.manager.DataTable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author chenkai
 * createTime 2017-11-2017/11/29 17:03
 */
@RestController
@RequestMapping("/api/expert")
public class ExpertController extends BaseController<Expert> {
    @Autowired
    private ExpertProductService expertProductService;

    @Autowired
    private ExpertService expertService;

    /**
     * 获取专家信息
     */
    @GetMapping("/{productId}")
    public ResultTo getExport(@PathVariable String productId) {
        List<ExpertProduct> productList = expertProductService.queryExpert(productId);
        return new ResultTo().setData(productList);
    }

    /**
     * 获取所有专家的专家
     */
    @GetMapping("/all")
    public ResultTo allExportUser() {
        List<ExpertVO> expertVOList = expertService.queryAllExpert(ManagerKit.getTopOrgId());
        return new ResultTo().setData(expertVOList);
    }

    @RequestMapping("/pageList")
    public ResultTo pageList() {
        return dataPage("queryExpertAll");
    }

}
